<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <a href="#">WMS</a>
            <i class="fa fa-circle"></i>
        </li>
        <li>
            <a href="#">Task</a>
            <i class="fa fa-circle"></i>
        </li>
        <li>
            <a>Replenishment Task</a>
        </li>
    </ul>
</div>
<div class="container-fluid" style="margin:15px">
    <div class="row">
        <div class="portlet light bordered">
            <div class="portlet-title">
                <div class="caption">
                    <span class="caption-subject bold"> Replenishment Task List</span>
                </div>
                <div class="actions">
                    <a ng-href="{{'#/wms/task/replenishment-task/history-search'}}" target="_blank">Replenishment History Search</a>
                </div>
            </div>
            <div class="portlet-body form form-horizontal">
                <form>
                    <div class="row form-group">
                        <div class="col-md-3">
                            <label>Task ID:</label>
                            <lt-tags-input ng-model="search.taskIds" placeholder="Enter Task ID" fill="TASK-" ng-keyup="keyUpSearch($event)"></lt-tags-input>
                        </div>
                        <div class="col-md-3">
                            <label>Item:</label>
                            <itemspec-auto-complete name="itemSpecId" ng-model="search.itemSpecId" name="itemSpec"
                                                    on-select="itemSpecIdOnSelect(itemSpec)" allow-clear="true"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            <label>Status</label>
                            <task-status-auto-complete  allow-clear="true"  ng-model="search.status"></task-status-auto-complete>
                        </div>
                        <div class="col-md-3">
                            <label>Priority:</label>
                            <task-priority-auto-complete allow-clear="true" ng-model="search.priority"></task-priority-auto-complete>
                        </div>
                    </div>

                    <div class="form-group form-actions right" >
                        <waitting-btn type="button" btn-class="btn blue" ng-click="searchTask()"
                                      value="'Search'" is-loading="loading"></waitting-btn>
                        <waitting-btn type="button" btn-class="btn green" ng-click="combineEAReplenishTasks()"
                                      value="'Combine EA Replenish Tasks'" is-loading="false"></waitting-btn>
                    </div>
                </form>
                <div ng-show="loading" class="text-center">
                    <img src="assets/img/loading-spinner-grey.gif" ><span >&nbsp;LOADING...</span>
                </div>
                <div ng-show="!loading" class="dataTables_wrapper no-footer">
                    <div class="table-scrollable">
                        <table class="table table-striped table-bordered table-hover table-checkable order-column dataTable no-footer"
                               id="sample_1" role="grid" aria-describedby="sample_1_info">
                            <thead>
                            <tr role="row">
                                <th> ID </th>
                                <th> Status</th>
                                <td> Priority </td>
                                <td> Assignee </td>
                                <th> Replenishment Item </th>
                                <th> Force Close Reason </th>
                            </tr>
                            </thead>
                            <tbody>
                                <tr ng-repeat="task in tasks track by $index">
                                    <td>
                                        <a ng-href="{{'#/wms/task/replenishment-task/view/' + task.id}}" target="_blank">{{task.id}}</a>
                                    </td>
                                    <td>{{task.status}}</td>
                                    <td>{{task.priority}}</td>
                                    <td>{{task.assignee.firstName}} {{task.assignee.lastName}}</td>
                                    <td>
                                        <span ng-repeat="replenishmentItem in task.replenishmentItems" ng-if="replenishmentItem" style="background-color:#f6f3e8; margin: 5px 5px;padding: 5px 10px;border-radius: 3px;">
                                            <item-display item="replenishmentItem"></item-display>&nbsp;|&nbsp;
                                            <span ng-repeat="property in replenishmentItem.product.diverseProperties">
                                                {{property.name}}: {{property.value}} {{property.unit}}&nbsp;|&nbsp;
                                            </span>&nbsp;{{replenishmentItem.qty}}&nbsp;{{replenishmentItem.unitName}}&nbsp;|&nbsp;
                                            <span ng-repeat="sn in replenishmentItem.snList">
                                                {{sn}}&nbsp;
                                            </span>&nbsp;|&nbsp;
                                            <span>{{replenishmentItem.toLocationName}}</span>
                                        </span>
                                    </td>
                                    <td>{{task.forceCloseReason}}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <pager total-count="paging.totalCount" current-page ="paging.pageNo" page-size="pageObj.pageSize"  load-content="loadContent(currentPage)"></pager>
                </div>
            </div>
            <!-- TABLE -->
        </div>
    </div>
</div>
